package org.jeecg.modules.business.third.strategy.sap;

import cn.hutool.core.util.ObjectUtil;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.modules.business.outbound.entity.WmsOutReceiptTaskMaterial;
import org.jeecg.modules.business.third.entity.WmsInReceiptMaterialVo;
import org.jeecg.modules.business.third.entity.WmsOutReceiptMaterialVo;
import org.jeecg.modules.business.warehouse.entity.WmsInReceiptTaskMaterial;

/*
 * 项目名称:    wms-server-jeecg
 * 接口描述:    参数校验
 * 创建人员:    zhaojun
 * 创建时间:    2023-10-23
 */
public class SapParamUtil {

    public static void validInTaskRecord(WmsInReceiptTaskMaterial one) {
        if (ObjectUtil.isEmpty(one)) {
            throw new JeecgBootException("当前入库单未找到任务明细记录");
        } else {
            if (StringUtils.isBlank(one.getExtraText())) {
                throw new JeecgBootException("当前入库单任务明细记录未保存，sap原始信息");
            }
        }
    }

    public static void validOutTaskRecord(WmsOutReceiptTaskMaterial one) {
        if (ObjectUtil.isEmpty(one)) {
            throw new JeecgBootException("当前出库单未找到任务明细记录");
        } else {
            if (StringUtils.isBlank(one.getExtraText())) {
                throw new JeecgBootException("当前出库单任务明细记录未保存，sap原始信息");
            }
        }
    }

    /**
     * 校验出库任务的创建是否有效
     *
     * @param wmsOutReceiptMaterialVo
     */
    public static void validWmsOutReceiptMaterial(WmsOutReceiptMaterialVo wmsOutReceiptMaterialVo) {
        if (StringUtils.isBlank(wmsOutReceiptMaterialVo.getOriginalSystemNumber())
                || StringUtils.isBlank(wmsOutReceiptMaterialVo.getOriginalSystemLineNumber())) {
            throw new JeecgBootException("当前任务为自建任务，无法进行sap过账处理");
        }
    }

    /**
     * 校验入库任务的创建是否有效
     *
     * @param wmsInReceiptMaterialVo
     */
    public static void validWmsInReceiptMaterial(WmsInReceiptMaterialVo wmsInReceiptMaterialVo) {
        if (StringUtils.isBlank(wmsInReceiptMaterialVo.getOriginalSystemNumber())
                || StringUtils.isBlank(wmsInReceiptMaterialVo.getOriginalSystemLineNumber())) {
            throw new JeecgBootException("当前任务为自建任务，无法进行sap过账处理");
        }
    }
}
